import requests

class FileSaver:
    def __init__(self, upload_url):
        self.upload_url = upload_url

    def save(self, filename, data, custom_param):
        files = {'file': (filename, data)}
        data = {'custom_param': custom_param}
        response = requests.post(self.upload_url, files=files, data=data)

        if response.status_code == 200:
            print("File uploaded successfully:", response.json())
        else:
            print("Failed to upload file:", response.status_code, response.text)

# 示例用法
if __name__ == "__main__":
    saver = FileSaver(upload_url="http://127.0.0.1:8000/upload/")
    with open("path/to/your/local/file.txt", "rb") as f:
        data = f.read()
    saver.save("file.txt", data, "your_custom_param")